<?php
function outGrade($grades) {

    $maxScore = $grades['一号裁判'];
    $maxJudge = '一号裁判';
    $minScore = $grades['一号裁判'];
    $minJudge = '一号裁判';
    $total = 0;
    $count = count($grades);


    foreach ($grades as $judge => $score) {
        $total += $score;

        if ($score > $maxScore) {
            $maxScore = $score;
            $maxJudge = $judge;
        }

        if ($score < $minScore) {
            $minScore = $score;
            $minJudge = $judge;
        }
    }


    $finalScore = round(($total - $maxScore - $minScore) / ($count - 2), 2);

    // 输出结果
    echo "打出最低分的裁判为：{$minJudge}，打分为：{$minScore}\n";
    echo "打出最高分的裁判为：{$maxJudge}，打分为：{$maxScore}\n";
    echo "最后得分为：{$finalScore}\n";
}


$grades = [
    '一号裁判' => 98.2,
    '二号裁判' => 97.5,
    '三号裁判' => 91,
    '四号裁判' => 89,
    '五号裁判' => 99,
    '六号裁判' => 98.5,
    '七号裁判' => 96.6,
    '八号裁判' => 93.4,
];

outGrade($grades);
